export default [
  {
    path: '/',
    redirect: '/home',
  },
  {
    path: '/home',
    name: 'Home',
    component: () => import('@/views/Home'),
    meta: { title: '菩提优购(liil.xyz)-慢少撇贵、全国不保' }
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/Login'),
    meta: { showFooter: false, showHeader: false, title: '菩提优购-欢迎登录' }
  },
  {
    path: '/register',
    name: 'Register',
    component: () => import('@/views/Register'),
    meta: { showFooter: false, showHeader: false, title: '菩提优购-欢迎注册' }
  },
  {
    path: '/search/:keyword?',
    name: 'Search',
    component: () => import('@/views/Search'),
    meta: { title: `商品搜索-菩提优购` }
  },
  {
    path: '/goods/:goodsId?',
    name: 'Goods',
    component: () => import('@/views/Goods'),
    meta: { title: '商品详情-菩提优购', keepAlive: true }
  },
  {
    path: '/addcart/:goodsNum?',
    name: "AddCart",
    component: () => import('@/views/AddCart'),
    meta: { title: '添加购物车成功-菩提优购' }
  },
  {
    path: '/shopcart',
    name: "ShopCart",
    component: () => import("@/views/ShopCart"),
    meta: { title: '购物车-菩提优购' }
  },
  {
    path: '/trade',
    name: "Trade",
    component: () => import("@/views/Trade"),
    meta: { title: '提交订单-菩提优购' },
    //局部路由守卫
    beforeEnter: (to, from, next) => {
      //判断是否从购物车页面路由过来 并且选择的商品数量必须大于大于1
      if (from.path == '/shopcart' && to.params.checkedNum >= 1) {
        next() //满足条件放行
      } else {
        next(false) //不是停留在当前页面
      }
    }
  },
  {
    path: '/pay',
    name: "Pay",
    component: () => import("@/views/Pay"),
    meta: { title: '支付中-菩提优购' },
  },
  {
    path: '/paysuccess',
    name: "PaySuccess",
    component: () => import("@/views/PaySuccess"),
    meta: { title: '支付成功-菩提优购' },
    beforeEnter: (to, from, next) => {
      //判断是否从购物车页面路由过来
      if (from.path == '/pay' && to.params.code == 200) {
        next()
      } else {
        next(false) //不是停留在当前页面
      }
    }
  },
  {
    path: '/center',
    name: "Center",
    component: () => import("@/views/Center"),
    children: [
      {
        path: 'myorder',
        name: 'MyOrder',
        component: () => import("@/views/Center/MyOrder"),
        meta: { title: '我的订单-个人中心' },
      },
      {
        path: 'grouporder',
        name: 'GroupOrder',
        component: () => import("@/views/Center/GroupOrder"),
        meta: { title: '团队订单-个人中心' },
      },
      { path: '/center', redirect: "/center/myorder" },

    ]
  }]
